package com.ikas.autumn.iec104.module.protocol.entity;

import com.ikas.autumn.iec104.module.protocol.enums.ProtocolEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Objects;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Connection {
    private ProtocolEnum protocolEnum;

    private String ip;
    private String port;

    private String username;
    private String password;
    private String clientId;


    public Connection(ProtocolEnum protocolEnum, String ip, String port) {
        this.protocolEnum = protocolEnum;
        this.ip = ip;
        this.port = port;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Connection that = (Connection) o;
        return protocolEnum == that.protocolEnum && Objects.equals(ip, that.ip) && Objects.equals(port, that.port) && Objects.equals(username, that.username) && Objects.equals(password, that.password) && Objects.equals(clientId, that.clientId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(protocolEnum, ip, port, username, password, clientId);
    }
}
